import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class LognPressGraggableDemo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('LognPressGraggable'),
        centerTitle: true,
      ),
      body: Center(
        child: LongPressDraggable(
          //child子组件，未进行拖拽时显示
          child: Container(
            width: 100,
            height: 100,
            color: Colors.blue,
          ),
          //feedback：跟随拖拽的组件
          feedback: Container(
            color: Colors.red,
            width: 100,
            height: 100,
          ),
          //childWhenDragging：拖拽时child子组件显示样式
          childWhenDragging: Container(
            color: Colors.amber,
            width: 100,
            height: 100,
          ),
          feedbackOffset: Offset(0, 10),
          //拖拽的锚地位置
          dragAnchor: DragAnchor.child,
          //拖动开始时调用
          onDragStarted: () {
            print('onDragStarted');
          },
          //拖动结束
          onDragEnd: (DraggableDetails details) {
            print('onDragEnd');
          },
          //在没有被DragTarget接受的情况下松开draggable时调用
          onDraggableCanceled: (Velocity velocity, Offset offset) {
            print('onDraggableCanceled');
          },
          //Draggable被删除并被DragTarget接受时调用
          onDragCompleted: (){
            print('onDragCompleted');
          },


        ),
      ),
    );
  }

}